import { Module } from "vuex";
import { IGlobalState } from "..";
import * as Types from '../action-types'

export interface IUserState {
  name: string,
  id: number,
  auth: string[],
}

const state: IUserState = {
  name: '',
  id: 0,
  auth: []
}

const user: Module<IUserState,IGlobalState> = {
  namespaced: true,
  state,
  mutations: {
    [Types.SET_USER_INFO](state, playload: IUserState) {
      state.auth = playload.auth
      state.name = playload.name
    },
    [Types.SET_USER_PERMISSIONS](state, playload: IUserState) {
      state.auth = playload.auth
    }
  },
  actions: {}
}

export default user